package com.container.app.testclasses;

import com.container.app.MContainer;
import com.container.app.MContainerManager;
import com.container.app.testclasses.configurations.InstancesImplementationsConfiguration;
import com.container.app.testclasses.configurations.ProviderConfiguration;
import com.container.app.testclasses.configurations.SimpleConfiguration;
import com.container.app.testclasses.fileinfo.FileInfoDisplay;
import com.container.app.testclasses.movies.MovieFinderSimpleImplementation;
import com.container.app.testclasses.movies.MovieLister;
import com.container.app.testclasses.providerexample.MagicNumber;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {
        System.out.println("Simple Inject Results(xml): ");

        MContainer container = new MContainerManager("simpleInject.xml");
        MovieLister movieLister = (MovieLister) container.getInstance(MovieLister.class);
        System.out.println(movieLister.listMovies());
        System.out.println();

        System.out.println("Deep Inject with multiple Implementation Results(xml): ");

        container.closeContainer();
        container = new MContainerManager("deepInject.xml");
        movieLister = (MovieLister) container.getInstance(MovieLister.class);
        System.out.println(movieLister.listMovies());
        System.out.println();

        System.out.println("Check if the same instance is returned: ");
        movieLister.setFinder(new MovieFinderSimpleImplementation());
        movieLister = (MovieLister) container.getInstance(MovieLister.class);
        System.out.println(movieLister.listMovies());
        System.out.println();

        container.closeContainer();
        System.out.println("Deep Inject with multiple Implementation Results(configuration class): ");
        container = new MContainerManager(SimpleConfiguration.class);
        movieLister = (MovieLister) container.getInstance(MovieLister.class);
        System.out.println(movieLister.listMovies());
        System.out.println();

        container.closeContainer();
        System.out.println("Inject Instances and multiple Implementation Results(configuration class): ");
        container = new MContainerManager(InstancesImplementationsConfiguration.class);
        FileInfoDisplay fileInfoDisplay = (FileInfoDisplay) container.getInstance(FileInfoDisplay.class);
        System.out.println(fileInfoDisplay.getInfo());
        System.out.println();

        container.closeContainer();
        System.out.println("Provider Results(configuration class): ");
        container = new MContainerManager(ProviderConfiguration.class);
        MagicNumber magicNumber = (MagicNumber) container.getInstance(MagicNumber.class);
        System.out.println(magicNumber.magicNumber());
        System.out.println(magicNumber.noMagicNumber());

        System.out.println(String.class.getClass());
        container.closeContainer();


    }
}
